const express = require("express");

const app = express();

// req请求对象
// res响应对象
// next 下一个中间件
app.use((req, res, next) => {
  console.log("logging:" + req.method + "," + req.url + "----" + Date.now());
  next();
});

app.get("/", (req, res) => {
  res.send("hello world");
});

app.post("/", (req, res) => {
  res.send("this is a post request");
});

app.put("/user", (req, res) => {
  res.send("get a put request at /user");
});

app.delete("/user", (req, res) => {
  res.send("get a delete request at /user");
});

app.listen(3000, () => {
  console.log("server is running in 3000");
});
